package com.feihong.yw189.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.feihong.yw189.R;

import java.util.List;


/**
 * 2017/2/17.
 */

public class PhoneNumDialog extends Dialog {

    private Context context;
    private TextView dialog_name;
    private List<String> mStr;
    private TextView[] rlPhoneNum = new TextView[5];

    private TextView  tvOne;
    private TextView  tvTow;
    private TextView  tvThree;
    private TextView  tvFour;
    private TextView  tvFive;

    public PhoneNumDialog(Context context, List<String> str) {
        super(context, R.style.QiaoDaoDialogStyle);
        this.context = context;
        this.mStr = str;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.phonenum_dialog);

        //tvOne=findViewById()


        rlPhoneNum[0] = (TextView) findViewById(R.id.dialog_one);
        rlPhoneNum[1] = (TextView) findViewById(R.id.dialog_tuo);
        rlPhoneNum[2] = (TextView) findViewById(R.id.dialog_three);
        rlPhoneNum[3] = (TextView) findViewById(R.id.dialog_four);
        rlPhoneNum[4] = (TextView) findViewById(R.id.dialog_five);

        dialog_name = (TextView) findViewById(R.id.dialog_name);
        for (int i = 0; i < rlPhoneNum.length; i++) {
            rlPhoneNum[i].setVisibility(View.GONE);
        }
        if(mStr != null && mStr.size() != 0){
            for (int i = 0; i < mStr.size(); i++) {
                rlPhoneNum[i].setVisibility(View.VISIBLE);
                rlPhoneNum[i].setText(mStr.get(i));
            }
            if(mStr.size() >= 5){
                dialog_name.setText("一证五户限制，不能办理");
            }else {
                dialog_name.setText("用户名下号码");
            }
        }else {
            dialog_name.setText("该用户名下暂无号码");
        }
        //dialog_name.setText(mStr);
    }


    @Override
    public void show() {
        super.show();
    }

    @Override
    public void dismiss() {

        super.dismiss();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            dismiss();
            return true;
        }
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            dismiss();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

}
